<script setup lang="ts">
import { ref, computed } from 'vue'
import { useUserStore } from '@/store/modules/user'

const $userStore = useUserStore()
const popType = computed(() => !$userStore.token)
// iphoneX以上机型底部安全距离
const safeHeight = ref(0)

uni.getSystemInfo({
  success: (res) => {
    if (res.safeAreaInsets) {
      safeHeight.value = res.safeAreaInsets.bottom
    }
  },
})

const handleNavToSign = () => {
  uni.reLaunch({ url: '/pages/sign/Index' })
}
</script>

<template>
  <u-popup v-model="popType" mode="bottom">
    <view class="authContent">
      <view class="authContent__top">登录后可继续当前操作</view>
      <button class="authContent__button" @click="handleNavToSign">立即登录</button>
      <!-- 底部占位误删 解决iphonex 底部bar -->
      <view :style="{ width: '100vw', height: safeHeight + 'px' }"></view>
    </view>
  </u-popup>
</template>

<style lang="scss" scoped>
@include b(authContent) {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;

  @include e(top) {
    height: 84rpx;
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 40rpx;
    font-size: 30rpx;
  }

  @include e(button) {
    border-radius: 100rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 60rpx;
    width: 80%;
    height: 90rpx;
    background-color: #fb5362;
    color: white;
    font-size: 30rpx;
  }

  @include e(noContent) {
    font-size: 30rpx;
    width: 400rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 40rpx;
  }
}
</style>
